﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class SpuCommentEntityTypeConfiguration : IEntityTypeConfiguration<SpuComment>
    {
        public void Configure(EntityTypeBuilder<SpuComment> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(SpuComment))
                .ToTable(tableBuilder => tableBuilder.HasComment("商品评价"));

            builder
                .HasKey(spuComment => spuComment.SpuCommentID)
                .HasName("SpuCommentID");

            builder
                .Property(spuComment => spuComment.SkuID)
                .HasColumnName("SkuID")
                .HasColumnType("int")
                .HasComment("SkuID")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.SpuID)
                .HasColumnName("SpuID")
                .HasColumnType("int")
                .HasComment("SpuID")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.SpuName)
                .HasColumnName("SpuName")
                .HasColumnType("nvarchar(255)")
                .HasComment("商品名字")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.MemberNickName)
                .HasColumnName("MemberNickName")
                .HasColumnType("nvarchar(255)")
                .HasComment("会员昵称")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.Star)
                .HasColumnName("Star")
                .HasColumnType("tinyint")
                .HasComment("星级")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.MemberIp)
                .HasColumnName("MemberIp")
                .HasColumnType("varchar(64)")
                .HasComment("会员ip")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.ShowStatus)
                .HasColumnName("ShowStatus")
                .HasColumnType("tinyint")
                .HasComment("显示状态[0-不显示，1-显示]")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.SpuAttrbutes)
                .HasColumnName("SpuAttrbutes")
                .HasColumnType("nvarchar(64)")
                .HasComment("购买时属性组合")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.LikesCount)
                .HasColumnName("LikesCount")
                .HasColumnType("int")
                .HasComment("点赞数")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.ReplayCount)
                .HasColumnName("ReplayCount")
                .HasColumnType("int")
                .HasComment("回复数")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.Resources)
                .HasColumnName("Resources")
                .HasColumnType("varchar(1000)")
                .HasComment("评论图片/视频[json数据；[{type:文件类型,url:资源路径}]]")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.Content)
                .HasColumnName("Content")
                .HasColumnType("text")
                .HasComment("内容")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.Content)
                .HasColumnName("Content")
                .HasColumnType("text")
                .HasComment("内容")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.MemberIcon)
                .HasColumnName("MemberIcon")
                .HasColumnType("varchar(255)")
                .HasComment("用户头像")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.CommentType)
                .HasColumnName("CommentType")
                .HasColumnType("tinyint")
                .HasComment("评论类型[0 - 对商品的直接评论，1 - 对评论的回复]")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(spuComment => spuComment.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
